package com.yeung.beans;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.NumberFormat;
import org.springframework.stereotype.Component;

import javax.validation.constraints.Past;
import java.util.Date;

/**
 * JSR303  是Java为bean 数据合法性校验提供的标准框架, hibernate也有类似的验证框架
 * 可以在数据行上标注类似于@NOtNUll\ @Max 等标准的注解来指定校验规则
 * 1. 需要加入它的依赖, 才能使用
 * 2. 需要在spring中配置
 */
@Component
public class Job {
    private int id;
    private String content;
    //告诉spring ,如何对时间日期数据的格式转换
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Past
    private Date time;
    @NumberFormat(pattern = "#,###,###.#")//说明数字的转换格式
    private Float salary;

    public Job() {
    }

    public Job(int id, String content, Date time) {
        this.id = id;
        this.content = content;
        this.time = time;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public Float getSalary() {
        return salary;
    }

    public void setSalary(Float salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Job{" +
                "id=" + id +
                ", content='" + content + '\'' +
                ", time=" + time +
                '}';
    }
}
